-
Notifications
You must be signed in to change notification settings - Fork 176
Add coverage target in Makefile for coverage reporting #71
Conversation
codecoverage/coverage-bin
Outdated
#!/bin/sh | ||
|
||
# This script is a proxy that injects the required test flags and strips out test output | ||
# It allows us to use a coverage-enabled binary for e2e tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a script for this? Can't it be done from the Makefile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we do; the script isn't called by the Makefile directly, but is invoked by the e2e test suite as if it was the actual docker-app
binary.
More details on why we're doing things this way if you're curious:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks.
.gitignore
Outdated
@@ -1,4 +1,5 @@ | |||
*.tar.gz | |||
*.dockerapp | |||
_build/ | |||
codecoverage/*.out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the output be moved into _build? This way all build intermediate files would be gathered in there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I can certainly do that.
You seem to have pushed the coverage branch to docker/lunchbox instead of shin-/lunchbox, is it on purpose? |
I got into the habit of doing that because the open source Jenkins would often ignore my PRs when submitted from my fork. I'll switch to shin-/lunchbox in the future. |
9b4460d
to
be08a48
Compare
Jenkinsfile
Outdated
sh 'make ci-coverage' | ||
archiveArtifacts 'cov/all.out' | ||
archiveArtifacts 'cov/coverage.html' | ||
sh 'curl -s https://codecov.io/bash | bash -s - -t 0b5323a7-aa90-4855-95ad-c859a917d611 -f cov/all.out -K' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put the codecov token here for the time being but ideally this would be a build variable in Jenkins or something - @mat007 would you be able to help with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll have a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I just realized this is actually uploading the reports to codecov…
So we don't really need to archive any artifacts nor copy files out of the container, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It comes down to what people expect out of this and how we'd like to leverage the results. If we're okay with being reliant on codecov to produce our report then we can skip the archiving.
OTOH, I'm ok with the extra ~40kB and 2 seconds of processing if it gives us more options.
Jenkinsfile
Outdated
steps { | ||
dir('src/github.com/docker/lunchbox') { | ||
checkout scm | ||
sh 'ls -la' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left over from debugging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw the ones I left by mistake lines 68, 81 and 94, would you mind removing them as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Jenkinsfile
Outdated
checkout scm | ||
sh 'ls -la' | ||
sh 'make ci-coverage' | ||
archiveArtifacts 'cov/all.out' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need all.out as an artifact?
Makefile
Outdated
ci-coverage: | ||
docker build --target=build -t $(IMAGE_NAME)-cov:$(TAG) $(IMAGE_BUILD_ARGS) . | ||
docker run --label $(COV_LABEL) $(IMAGE_NAME)-cov:$(TAG) make COMMIT=$(TAG) TAG=$(COMMIT) coverage | ||
docker cp $$(docker ps -aql --filter label=$(COV_LABEL)):$(PKG_PATH)/_build/cov/ ./cov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ./cov
creates a folder out of _build
when running make ci-coverage
locally (I know we're not really supposed to but it proves useful as a poor man's building environment which only requires docker and make).
I suppose it all depends on what we want to do with the coverage reports in the end, a tar.gz might not be very useful…
Currently the generated HTML does not display well as an artifact on Jenkins, see https://ci.baguette.docker.paris/job/lunchbox/view/change-requests/job/PR-71/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, one would have to download the HTML file to view it correctly I imagine.
Jenkinsfile
Outdated
agent { | ||
label 'gcp-linux-worker-0' | ||
} | ||
steps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, if I have the secret configured correctly on the Jenkins side, here you only need to add
environment {
CODECOV_TOKEN = credentials('jenkins-codeconv-token')
}
and then remove the -t
flag below and that should be it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Secret configuration page for lunchbox on Jenkins: https://ci.baguette.docker.paris/job/lunchbox/credentials/store/folder/domain/_/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Side note: It looks like I'm not authorized to access that page)
To tie up the threads on the artifacts discussion: I kept things broad for the time being so we can weigh our options. If we feel some are redundant or seldom useful, I'm happy to remove them. |
Jenkinsfile
Outdated
@@ -44,7 +44,7 @@ pipeline { | |||
parallel { | |||
stage("Coverage report") { | |||
environment { | |||
CODECOV_TOKEN = credentials('jenkins-codecov-token') | |||
CODECOV_TOKEN = credentials('jenkins-codeconv-token') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops, sorry, I'll fix that right away…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, fixed, you can remove the last commit, sorry about that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
d7ba3a8
to
dfa4d2e
Compare
@chris-crone any opinion about how we might want to use the coverage report data? |
Rebased + fixed some issues with the script uncovered by the new e2e tests |
Codecov Report
@@ Coverage Diff @@
## master #71 +/- ##
=========================================
Coverage ? 39.57%
=========================================
Files ? 40
Lines ? 2332
Branches ? 0
=========================================
Hits ? 923
Misses ? 1248
Partials ? 161 Continue to review full report at Codecov.
|
Something to take into account on https://codecov.io/gh/docker/lunchbox/pull/71/tree though, pretty sure it doesn't cover any packages that has no tests (so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vendoring seems to have issues?
Jenkinsfile
Outdated
environment { | ||
CODECOV_TOKEN = credentials('jenkins-codecov-token') | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra blank line
Makefile
Outdated
@echo "Running e2e tests (coverage)..." | ||
DOCKERAPP_BINARY=../e2e/coverage-bin $(GO_TEST) -v ./e2e | ||
@echo "Running unit tests (coverage)..." | ||
$(GO_TEST) -cover -test.coverprofile=_build/cov/unit.out $(shell go list ./... | grep -vE '/vendor/|/e2e') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: vendor
is actually not listed by go list
by default
@@ -20,7 +20,7 @@ type options struct { | |||
} | |||
|
|||
// flatten flattens a structure: foo.bar.baz -> 'foo.bar.baz' | |||
func flatten(in map[string]interface{}, out map[string]interface{}, prefix string) { | |||
func flatten(in map[string]interface{}, out map[string]string, prefix string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this was intended to change yatee?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,27 @@ | |||
Copyright (c) 2015 The Polymer Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What version of dep
are you using? There seems to be a lot of license files being added here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest, AFAICT:
$ dep version
dep:
version : v0.4.1
build date : 2018-01-24
git hash : 37d9ea0a
go version : go1.9.1
go compiler : gc
platform : linux/amd64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM, thanks @shin-!
Dockerfile
Outdated
git | ||
git \ | ||
util-linux \ | ||
bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I like to sort these alphabetically so that it's easier to see if something is installed or not
[[override]] | ||
name = "github.com/spf13/pflag" | ||
branch = "master" | ||
source = "github.com/shin-/pflag" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to upstream your changes here so that we don't need to rely on a fork
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR submitted: spf13/pflag#169
I'll keep an eye on it and update if anything happens.
@@ -20,7 +20,7 @@ type options struct { | |||
} | |||
|
|||
// flatten flattens a structure: foo.bar.baz -> 'foo.bar.baz' | |||
func flatten(in map[string]interface{}, out map[string]interface{}, prefix string) { | |||
func flatten(in map[string]interface{}, out map[string]string, prefix string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shin- I think you need to rebase on master and then run |
No need for the dep ensure, a rebase should take care of that since the operation was done on master. |
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
Updated, PTAL! |
No description provided.